<template>
    <div>
        <h1>登录页面</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="info.name" /></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="info.pwd" /></td>
                </tr>
               <tr>
                <td></td>
                <td>
                    <button @click="login">登录</button>
                </td>
               </tr>

            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import moment from 'moment';
import { useRouter, useRoute } from 'vue-router';

const router = useRouter();
const route = useRoute();
let info:any=reactive({
    name: '',
    pwd: '',

})

const login=()=>{
    if(info.name==''){
        alert('用户名不能为空')
        return;
    }
    if(info.pwd==''){
        alert('密码不能为空')
        return; 
    }
   axios({
     url:'/api/yisheng/Login',
     method:'get',
     params :info
   }) 
   .then(res=>{
     if(res.data==3){
       alert('用户名不正确') 
       return;
     } 
     if(res.data==2){
        alert('密码不正确')
        return;
     }
     if(res.data==1){
       alert('登录成功')  
        router.push('/Showbingfang'); 

     }
   })
}

</script>

<style scoped>

</style>